<template>
  <!--1. 容器 -->
  <div ref="left1_container" id="container" style="height: 95%"></div>
</template>

<script>
//2.引入折线图构造函数
import { Line } from "@antv/g2plot"
import {get} from '../../../utils/request'
import moment from 'moment'
export default {
  data() {
    return {
      dataArr: [],
    };
  },
  created() {},
  mounted() {
    //5.调用
    this.initData();
  },
  methods: {
    initData(){
      get('/dashboard/pageQueryTodayData',{
        page: 1,
        pageSize: 5,
        device_id: 1,
        
      }).then(res => {
        res.data.list.forEach(item => {
          item.dataTime = moment(item.insert_time).format('HH:mm')
        });
        this.dataArr= res.data.list;
        console.log(4444,this.dataArr);
        this.initChart()
      })
    },
    
    initChart() {
      //3.创建一个折线图实例对象 'container'=this.$refs.left1_container
      const line = new Line("container", {
        data: this.dataArr,
        xField: "dataTime",
        yField: "temperature",
        
      });
      //4.渲染图像
      line.render();
    },
  },
};
</script>

<style scoped>
</style>